import {BigNumber} from 'bignumber.js';

export function copy(data) {
	// #ifdef H5
	copyToClipboard(data)
	// #endif

	// #ifndef H5
	console.log("copy")
	uni.setClipboardData({
		data,
		success: function() {
			console.log('copy success');
		}
	});
	// #endif
}
/**
 * Check if it has expired
 * @param lastTime Last recorded time in milliseconds
 * @param range Expiration time
 */
export function isTimeInvalid(lastTime, range){
	let currentTime = new Date().getTime();
  return currentTime - lastTime - range  > 0
};

//Shuffle the array
export function randomArraySort (array){
    let len = array.length;
    let arr = [...array];
    for(let i=len-1;i>=0;i--){
      let randomIndex = Math.floor(Math.random() * (i+1));
      let itemIndex = arr[randomIndex];
      arr[randomIndex] = arr[i];
      arr[i] = itemIndex;
    }
    return arr;
}
